package net.oschina.app.previousTest;

import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import com.robotium.solo.Solo;

import net.oschina.app.AppStart;

/**
 * Created by Administrator on 2017/7/1.
 */

public class ListViewTest extends ActivityInstrumentationTestCase2 {

    private Solo solo;

    public ListViewTest(){
        super(AppStart.class);
    }

    @Override
    public void setUp() throws Exception {
        super.setUp();
        solo = new Solo(getInstrumentation(),getActivity());
    }

    public void testName() throws Exception {
      /*  solo.sleep(5000);
        //定位 列表框
        ListView list = (ListView) solo.getView("net.oschina.app:id/listView");
        //遍历  标题
        String title = "源创会 | 济南站开始报名啦！";
        int index = -1;
        for (int i = 0; i < list.getChildCount(); i++) {
            //list.getChildAt(i)  : 取列表的某一行
            View view = list.getChildAt(i);
            TextView titleTv = (TextView) view.findViewById(R.id.tv_title);
            if (titleTv != null){
                //获取的文本包括 title的内容ListViewTest
                if (titleTv.getText().toString().contains(title)){
                    index = i;
                    break;
                }
            }
        }
        Log.i("AUTO","the index of new expected news title is "+index);*/

        solo.sleep(4000);
        //定位 listview
        int count = solo.getCurrentViews(ListView.class).size();
        Log.i("AUTO","ListView count :"+count);

        for (ListView view : solo.getCurrentViews(ListView.class)){
            Log.i("AUTO",view.getChildCount() +"");
        }

    }

    @Override
    public void tearDown() throws Exception {
        solo.finishOpenedActivities();
        super.tearDown();
    }
}
